﻿// // --------------------------------------------------------------------------------------------------------------------
// // <copyright file="SPTWikiPage.cs" company="Collaboris">
// //   Copyright Collaboris
// // </copyright>
// // <summary>
// //   
// // </summary>
// // --------------------------------------------------------------------------------------------------------------------

namespace Collaboris.ShareTest.SharePoint2010.PageObjects.AppPages
{
    #region

    using Collaboris.ShareTest.Core;
    using Collaboris.ShareTest.SharePoint2010.Actions;

    using OpenQA.Selenium;
    using OpenQA.Selenium.Remote;

    #endregion

    /// <summary>
    /// 	SharePoint Wiki Page
    /// </summary>
    public class SPTWikiPage : SPTPageObjectBase
    {
        #region Constructors and Destructors

        /// <summary>
        /// 	Initializes a new instance of the <see cref = "SPTWikiPage" /> class.
        /// </summary>
        /// <param name = "driver">
        /// 	The Driver.
        /// </param>
        /// <param name = "fullUrl">
        /// </param>
        public SPTWikiPage(RemoteWebDriver driver, string fullUrl)
            : base(driver, fullUrl)
        {
        }

        public SPTWikiPage(RemoteWebDriver driver, string fullUrl, string verifyElementOnLoad)
            : base(driver, fullUrl, verifyElementOnLoad)
        {
        }

        public SPTWikiPage(RemoteWebDriver driver, string fullUrl, string verifyElementOnLoad, string loginFileName)
            : base(driver, fullUrl, verifyElementOnLoad, loginFileName)
        {
        }

        #endregion

        #region Public Methods

        /// <summary>
        /// 	This method adds the DocRead web part to the 
        /// 	home page (if its not already there).
        /// </summary>
        /// <param name = "webPartCategory">
        /// 	The web Part Category.
        /// </param>
        /// <param name = "webPartTitle">
        /// 	The web Part Title.
        /// </param>
        public void AddWebPart(string webPartCategory, string webPartTitle)
        {
            // IWebElement result = this.intranetWebDriver.FindElement(By.LinkText(Dr.SPTWikiPage.MyReadingListTitle));
            Logger.LogMessage("Adding Web Part " + webPartTitle);

            // click edit page
            SiteActionsMenu.Click_EditPage_Menu(this.webDriver);

            // click insert on ribbon
            Ribbon.Click_Insert_Tab(this.webDriver);

            // click in the wiki content 
            this.webDriver.FindElement(By.CssSelector("div.ms-rte-layoutszone-inner-editable.ms-rtestate-write")).Click(
                );

            // click insert web part
            Ribbon.Insert.Click_WebPart_Button(this.webDriver);

            // select Docread Web parts
            Ribbon.WebPartMenu.Click_Category(this.webDriver, webPartCategory);

            // click the all users web part
            Ribbon.WebPartMenu.Click_WebPart(this.webDriver, webPartTitle);

            // click the web part "Add" button
            Ribbon.WebPartMenu.Click_Add_Button(this.webDriver);

            // click the "Page" tab on the ribbon
            Ribbon.Click_Page_Tab(this.webDriver);

            // click the close and save button
            // SiteActionsMenu.Click_SaveAndClose_Button(this.intranetWebDriver);
        }

        #endregion
    }
}